require 'rubygems'
require 'rake'
require 'rake/testtask'

task :default => [:help]

# Help!
task :help do
  puts "You should really read the README or the documentation!"
  puts "Run tests:              rake test"
  puts "Run server:             rake server"
  puts "Run client:             rake client"
  puts "Rebuild documentation:  rake doc"
end

# Generate the documentation
task :doc do
  unless system 'rm -rf doc' # delete doc dir on *nix OS
    system 'RMDIR /s /q doc' # delete doc dir on winblows
  end
  system 'rdoc --main lib/distributed_worker.rb'
end

# Run unit tests
Rake::TestTask.new do |t|
  t.libs << 'test'
  t.test_files = FileList['test/*.rb']
  t.verbose = true
end

# Run the server instance
task :server do
  ruby 'bin/server.rb'
end

# Run the client instance
task :client do
  ruby 'bin/client.rb'
end
